package me.zhengjie.resources.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;

@Slf4j
public class SerialUtils {

    public static  <T> byte[] serialize(T object) {
        try {
            ByteArrayOutputStream bao = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(bao);
            oos.writeObject(object);
            return bao.toByteArray();
        } catch (Exception var4) {
            log.error(var4.getMessage(), var4);
            throw new RuntimeException(var4.getMessage(), var4);
        }
    }

}
